package com.example.zkweixiu.app.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.zkweixiu.app.R;
import com.example.zkweixiu.app.bean.MangeBean;
import com.example.zkweixiu.app.pro.PublicPro;
import com.yanzhenjie.sofia.Sofia;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.joda.time.DateTime;

/***
 * 客户信息
 *
 * */
public class UserDataActivity extends AppCompatActivity {

    private TextView tv_names;
    private TextView tv_names1;
    private TextView tv_names2;
    private TextView tv_names3;
    private TextView tv_names4;
    private TextView tv_names5;
    private TextView tv_names6;
    private TextView tv_names7;
    private TextView tv_names8;
    private TextView tv_names9;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_data);
        Sofia.with(UserDataActivity.this).statusBarDarkFont().statusBarBackground(Color.parseColor("#E6E8ED"));

        initView();

        EventBus.getDefault().register(this);

    }

    private void initView() {
        tv_names = findViewById(R.id.tv_names);
        tv_names1 = findViewById(R.id.tv_names1);
        tv_names2 = findViewById(R.id.tv_names2);
        tv_names3 = findViewById(R.id.tv_names3);
        tv_names4 = findViewById(R.id.tv_names4);
        tv_names5 = findViewById(R.id.tv_names5);
        tv_names6 = findViewById(R.id.tv_names6);
        tv_names7 = findViewById(R.id.tv_names7);
        tv_names8 = findViewById(R.id.tv_names8);
        tv_names9 = findViewById(R.id.tv_names9);
        ImageView iv_fig = findViewById(R.id.iv_fig);

        iv_fig.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }

    @Override
    public void onStart() {
        super.onStart();
    }

    @Override
    public void onStop() {
        super.onStop();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onMessageEvent(MangeBean.DataBean.RowsBean event) {

        tv_names.setText(PublicPro.userBean.getData().getGuaName());
        Log.e("onMessageEvent", "收到");
        tv_names1.setText(event.getOpeUser());
        tv_names2.setText(event.getUserName());
        tv_names3.setText(event.getPactNumber());
        tv_names4.setText(event.getUserPhone());
        tv_names5.setText(event.getSetUuid());
        tv_names6.setText(event.getAppAddressAll());
        tv_names7.setText(event.getLatitude() + ", " + event.getLongitude());
        tv_names8.setText(event.getSetAlias());

        DateTime dateTime = new DateTime();

        if (event.getSetBindTime() == null) {
            tv_names9.setText("暂未获取");
        } else {
            String s = dateTime.withMillis(event.getSetBindTime()).toString("yyyy/MM/dd HH:mm:ss");//系统时间格式化
            tv_names9.setText("信息创建时间" + s);

        }
        //  tv_names8.setText(event.getLatitude()+", "+event.getLongitude());
    }
}
